import java.io.InputStream;

import org.kwis.msp.lcdui.Display;
import org.kwis.msp.lcdui.Jlet;

import org.kwis.msp.media.Clip;
import org.kwis.msp.media.Player;
import org.kwis.msp.handset.HandsetProperty;

import org.kwis.msp.lwc.Component;
import org.kwis.msp.lwc.LabelComponent;
import org.kwis.msp.lwc.ShellComponent;


public class ClipEx2 extends Jlet {   
	
	protected void startApp(String[] arg0) {
		try {

			Clip clip = new Clip("audio/MIDI");

			int inStreamLength;
			byte[] buffer ;

			InputStream inStream = getClass().getResourceAsStream("/music.mid");
			
			inStreamLength=inStream.available();
			buffer = new byte[inStreamLength];
			inStream.read(buffer);
			
			clip.setBuffer(buffer,inStreamLength);

			Player.play(clip, true);
			inStream.close();

		}catch(Exception e) {}


		Display displayLCD = Display.getDefaultDisplay();
		ShellComponent shell = new ShellComponent();

		shell.setTitle("  Clip Play ");

		shell.show();

	}
	
	protected void destroyApp(boolean unconditional) {
	}

}